
<%@ page import="org.xilin.Teacher" %>

<g:setProvider library="jquery"/>

<div>
    <g:if test="${flash.message}">
      <div class="message" style="display:none">${flash.message}</div>
    </g:if>
  
    <g:hasErrors bean="${teacherInstance}">
      <div class="errors" style="display:block">
          <g:renderErrors bean="${teacherInstance}" as="list" />
      </div>
    </g:hasErrors>

    <g:hasErrors bean="${teacherInstance.user}">
      <div class="errors" style="display:block">
          <g:renderErrors bean="${teacherInstance.user}" as="list" />
      </div>
    </g:hasErrors>

    <g:formRemote name="saveTeacher" url="${[action:'save']}" method="post" update="cluetip-inner" before="beforeSave()" onComplete="processResponse()">
        <g:hiddenField name="view" value="create" />
        <div class="dialog">
            <table>
                <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="user"><g:message code="teacher.firstName.label" default="First Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'firstName', 'errors')}">
                          <g:textField name="firstName" value="${teacherInstance?.firstName}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="user"><g:message code="teacher.lastName.label" default="Last Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'lastName', 'errors')}">
                          <g:textField name="lastName" value="${teacherInstance?.lastName}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="user.username"><g:message code="teacher.user.username.label" default="Username" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'user.username', 'errors')}">
                          <g:textField name="user.username" value="${teacherInstance?.user?.username}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="user.passwd"><g:message code="teacher.user.passwd.label" default="Password" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'user.passwd', 'errors')}">
                          <g:passwordField name="user.passwd" value="${teacherInstance?.user?.passwd}" />                          
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="user.email"><g:message code="teacher.user.email.label" default="Email" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'user.email', 'errors')}">
                          <g:textField name="user.email" value="${teacherInstance?.user?.email}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="type"><g:message code="teacher.type.label" default="Type" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'type', 'errors')}">
                          <g:textField name="type" value="${teacherInstance?.type}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="course"><g:message code="teacher.course.label" default="Course" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'course', 'errors')}">
                            <g:select name="course.id" from="${org.xilin.Course.list()}" optionKey="id" value="${teacherInstance?.course?.id}"  />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="semester"><g:message code="teacher.semester.label" default="Semester" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: teacherInstance, field: 'semester', 'errors')}">
                            <g:select name="semester.id" from="${org.xilin.Semester.list()}" optionKey="id" value="${teacherInstance?.semester?.id}"  />
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <br/>
        <div class="buttons">
            <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
            <span class="button"><input type="reset" value="${message(code: 'default.button.clear.label', default: 'Reset')}" /></span>
        </div>
    </g:formRemote>
</div>
